<template>
  <div id="app">
    <router-view></router-view>
  </div>
</template>
<script>
export default {
    created() {
        if (typeof document.addEventListener === 'undefined') {
            console.error('浏览器不支持addEventListener,请升级');
        } else {
            document.addEventListener('visibilitychange', () => {
                if (document.visibilityState == 'hidden') {
                }
            });
            window.addEventListener('beforeunload', () => {
                let url = this.$route.path;
                if (url.indexOf('/main') != '-1' && url != '/main') {
                    localStorage.setItem('url', this.$route.path);
                }
            });
        }
        let token = localStorage.getItem('gcp_token');
        let oprid = localStorage.getItem('gcp_oprid');
        if (token && oprid) {
            let url = localStorage.getItem('url');
            if (!!url) {
                if (url.indexOf('/main') != '-1' && url != '/main') {
                    setTimeout(() => {
                        this.$router.push('/main/dashboard');
                    }, 600);
                }
            }
        }
    }
};
</script>
<style>
@import './assets/css/main.css';
/* 深色主题 */
@import './assets/css/color-dark.css';
/* 浅绿色主题 */
/* @import "./assets/css/theme-green/color-green.css"; */
</style>
